<!--suppress ALL -->
<template>
	<view class="form"  :style="{height:screenHeight+'px'}">
		<view>
			<u-navbar :title="title" @leftClick="leftClick" :autoBack="true" :placeholder="true" fixed border
				leftText="返回">
			</u-navbar>
		</view>
		<view class="formINFO" ref="HotWork">
			<Form :type="pageTyep" @submit="submit" v-if='pageCheck === 0' ref="baseForm"></Form>
			<hazardousCheck v-else-if="pageCheck === 1 " @whbsSubmit="cardSubmit" :pageCheck="pageCheck" :params="form.params">
			</hazardousCheck>
			<protectionCheck v-else-if="pageCheck === 2" :pageCheck="pageCheck" @grfhSubmit='grfh'></protectionCheck>
			<safetyCheck v-else-if="pageCheck === 3" :pageCheck="pageCheck" @aqcsSubmit='aqcs'></safetyCheck>
			<Gas v-else-if="pageCheck === 4" :pageCheck="pageCheck" @fzr="fzr" :pageTyep="pageTyep"></Gas>
			<Reviewer v-else-if="pageCheck === 5" :pageCheck="pageCheck" :form="form" :pageTyep="pageTyep"></Reviewer>
		</view>
	</view>
</template>

<script>
	import deptPick from "@/pages/Components/department";
	import {
		workHeaderAPI
	} from '@/api/public.js'
	import hazardousCheck from '../components/hazardousCheck/hazardousCheck'
	import protectionCheck from '../components/protectionCheck/protectionCheck'
	import safetyCheck from '../components/safetyCheck/safetyCheck'
	import Gas from '../components/gas/gas'
	import Reviewer from '../components/Reviewer/Reviewer'
	import Form from '@/pages/Components/formMessage/formMessage'

	export default {
		components: {
			deptPick,
			hazardousCheck,
			protectionCheck,
			safetyCheck,
			Gas,
			Reviewer,
			Form
		},
		data() {
			return {
        screenHeight:null,
				title: '',
				pageCheck: 0,
				pageTyep: 1,
				btnMessage: {
					state: false,
					cancels: '上一步',
					submit: '下一步',
				},
				formModel: {
					name: "",
					userPicker: "",
					datetime: "",
					picker: "",
				},
        from:{
          baseForm:null,
        },
				formList: [],
				form: {
					list: null,
					whbsIds: null,
					grypfhIds: null,
					aqcsIds: null,
					qmtp: null,
					ry: uni.getStorageSync('userId'),
					orgCode: uni.getStorageSync('companyId')
				},
			}
		},
		onLoad(id) {
      uni.getSystemInfo({
        success: res => {
          this.screenHeight = parseInt(res.windowHeight)
        }
      });
			this.pageTyep = id.id
			this.title = id.name
		},
		methods: {
			leftClick() {
				uni.navigateTo({
					url: "../operationTicket/index/index"
				})
			},
			submit(val) {
				this.form.list = val.list
				this.form.params = val.params
				this.pageCheck++
			},
			fzr(val) {
				console.log('签字页', val)
				this.form.qmtp = val.fileUrl
				this.form.qzy = val.value
				this.pageCheck = val.step
			},
			cardSubmit(val) {
				console.log('危害辨识(父)', val)
        this.from.baseForm = val.from
				let msg = val.value.map((e) => {
					return e.value
				})
				this.form.whbsIds = msg.toString()
				this.pageCheck = val.step
			},
			grfh(val) {
				console.log('个人防护(父)', val)
				let msg = val.value.map((e) => {
					return e.value
				})
				this.form.grypfhIds = msg.toString()
				this.pageCheck = val.step
			},
			aqcs(val) {
				console.log('安全措施(父)', val)
				let msg = val.value.map((e) => {
					return e.value
				})
				this.form.aqcsIds = msg.toString()
				this.pageCheck = val.step
			},
			URL(val) {
				this.pageCheck = val
			},
		}
	}
</script>
<style lang="scss" scoped>
	.form {
		// height: calc(100vh - 10rpx);
		overflow-y: auto;
		background: #f6f6f6;

		.formINFO {
			// box-sizing: border-box;
			border-radius: 8px;
			background: #FFF;
			padding: 0 35rpx;
			margin: 25rpx 30rpx 0 30rpx;
		}
	}
</style>
